﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Things.Common;
using LTP.Accounts.Bus;
namespace Things.Web.Factory
{
    public partial class Add : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSave_Click(object sender, EventArgs e)
        {

            string strErr = "";
            if (this.txtFactoryName.Text.Trim().Length == 0)
            {
                strErr += "工厂名称不能为空！\\n";
            }
            if (this.txtAddress.Text.Trim().Length == 0)
            {
                strErr += "厂址不能为空！\\n";
            }
            if (this.txtPhone.Text.Trim().Length == 0)
            {
                strErr += "联系电话不能为空！\\n";
            }
            if (this.txtLicense.Text.Trim().Length == 0)
            {
                strErr += "生产经营许可证不能为空！\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string FactoryName = this.txtFactoryName.Text;
            string Address = this.txtAddress.Text;
            string Phone = this.txtPhone.Text;
            string License = this.txtLicense.Text;
            bool IsDeleted = false;

            Things.Model.Factory model = new Things.Model.Factory();
            model.FactoryName = FactoryName;
            model.Address = Address;
            model.Phone = Phone;
            model.License = License;
            model.IsDeleted = IsDeleted;

            Things.BLL.Factory bll = new Things.BLL.Factory();
            bll.Add(model);
            Things.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "add.aspx");

        }


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
